﻿using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using UnityEngine;
using UnityEngine.EventSystems;

public static class EventSystemExtension
{
    public static List<RaycastResult> RaycastAll(this EventSystem eventSystem, Vector3 position)
    {
        return eventSystem.RaycastAll(position, new List<RaycastResult>());
    }

    public static List<RaycastResult> RaycastAll(this EventSystem eventSystem, Vector3 position, List<RaycastResult> result)
    {
        PointerEventData eventData = new PointerEventData(eventSystem) {
            position = position
        };
        eventSystem.RaycastAll(eventData, result);
        return result;
    }
}

